const mysql = require('mysql2')

const connection = mysql.createConnection({
    'host': '127.0.0.1',
    'user': 'mydb',
    'password': 'mydb',
    'database': 'testmydb'
})
connection.connect()

//定义修改记录的SQL语句和参数
var updateSql = 'UPDATE bookinfo SET author = ?,price = ? WHERE id = ?';
var updateSql_Params = ['向大大', 88.80, 13];
//通过查询命令执行修改操作
connection.query(updateSql, updateSql_Params, function(err, result) {
    if (err) throw err;
    console.log('-------修改记录----------');
    console.log('修改所影响的行数:', result.affectedRows);
    console.log('修改所改变的行数:', result.changedRows);
});
connection.end();